package com.lxd.milktea.service.impl;

import com.lxd.milktea.dao.CategoryRepository;
import com.lxd.milktea.dataobject.Category;
import com.lxd.milktea.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ProjectName: milktea
 * @Package: com.lxd.milktea.service.impl
 * @ClassName: CategoryServiceImpl
 * @Author: carrymaniac
 * @Description:
 * @Date: 2020/5/3 1:51 下午
 * @Version:
 */
@Service
public class CategoryServiceImpl implements CategoryService {
    @Autowired
    private CategoryRepository categoryRepository;
    @Override
    public List<Category> findByCategoryTypeIn(List<Integer> categoryTypeList) {
        return categoryRepository.findAllByCategoryTypeIn(categoryTypeList);
    }

    @Override
    public Category findOne(Integer categoryId) {
        //todo 做异常处理
        return categoryRepository.findById(categoryId).get();
    }

    @Override
    public List<Category> findAll() {
        return categoryRepository.findAll();
    }

    @Override
    public Category save(Category category) {
        return categoryRepository.save(category);
    }
}
